package com.chenjt.four_aiservicedemo;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.service.SystemMessage;
import dev.langchain4j.service.UserMessage;
import dev.langchain4j.service.V;

import java.io.IOException;

/**
 * 注释：
 *
 * @author chenjt
 * @date 2025/3/7 17:04
 */
public class AiWriter {


    interface Writer{
        @SystemMessage("你是一个散文作家，根据输入的题目写一篇200字以内的散文")
        String write(String content);
    }

    interface Writer2{
        @SystemMessage("你是一个散文作家，题目是{{title}}，字数不超过{{count}}个字")
        String write(@UserMessage String content, @V("title")String title, @V("count")Long count);
    }

    public static void main(String[] args) throws IOException {

        ChatLanguageModel model = OpenAiChatModel.builder()
                .apiKey("demo")
                .modelName("gpt-4o-mini")
                .build();

//        Writer writer = AiServices.create(Writer.class, model);
//        String content = writer.write("我应该感谢谁");
//        System.out.println(content);



        Writer2 writer = AiServices.create(Writer2.class, model);
        String content = writer.write("写一篇作文","最爱看的电影",200L);
        System.out.println(content);



    }


}
